package com.freesky.biz.rights.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.freesky.biz.rights.domain.RightsSinopecTaskEntity;
import com.freesky.biz.rights.mapper.RightsSinopecTaskMapper;
import com.freesky.biz.rights.service.IRightsSinopecTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RightsSinopecTaskServiceImpl extends ServiceImpl<RightsSinopecTaskMapper, RightsSinopecTaskEntity>  implements IRightsSinopecTaskService {

    @Autowired
    private RightsSinopecTaskMapper rightsSinopecTaskMapper;

    @Override
    public RightsSinopecTaskEntity selectLatestTask() {
        LambdaQueryWrapper<RightsSinopecTaskEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(RightsSinopecTaskEntity::getDelFlag,"0");
        queryWrapper.orderByDesc(RightsSinopecTaskEntity::getCreateDate);
        queryWrapper.last("limit 1");
        return rightsSinopecTaskMapper.selectOne(queryWrapper);
    }

    @Override
    public int addRightsSinopecTask(RightsSinopecTaskEntity rightsSinopecTask) {
        return rightsSinopecTaskMapper.insert(rightsSinopecTask);
    }

    @Override
    public int updateRightsSinopecTask(RightsSinopecTaskEntity rightsSinopecTask) {
        return rightsSinopecTaskMapper.updateById(rightsSinopecTask);
    }
}
